class Solution
{
public:
    bool check(vector<int> &nums)
    {
        int decreaseCount = 0;
        int n = nums.size();
        for (int i = 1; i < n; ++i)
        {
            if (nums[i] < nums[i - 1])
            {
                ++decreaseCount;
            }
        }
        if (decreaseCount == 0)
        {
            return true;
        }
        if (decreaseCount == 1)
        {
            return nums[0] >= nums[n - 1];
        }
        return false;
    }
};